package com.david.utils;

import com.david.dao.CacheMapper;
import com.david.entity.Goods;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

/**
 * @description: 缓存预热配置
 * @create: 2021-04-29-21-33
 * @author: David
 **/
@Component
public class RedisCache {

    @Resource
    CacheMapper cacheMapper;

    /**
     * 秒杀未开始的时候查询商品信息，来将其加入缓存中
     * @return 返回商品信息
     */
    @Cacheable(value = "redisCache", key = "'Goods'")
    public Goods findGoods(Integer id){
        return cacheMapper.findGoods(id);
    }

}
